package com.catmiao.sql;


import org.apache.spark.SparkConf;
import org.apache.spark.SparkContext;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.sql.SparkSession;

/**
 * 环境之间的转换
 */
public class Spark04_env_convert {

    public static void main(String[] args) {


        SparkSession sparkSession = SparkSession
                .builder()
                .master("local[*]")
                .appName("SparkSQL")
                .getOrCreate();


        // 环境之间的转换
        // TODO  Core: SparkContext -> SQL: SparkSession
        SparkSession sparkSession1 = new SparkSession(new SparkContext(new SparkConf()));
        // TODO  SQL：SparkSession -> Core：SparkContext
        SparkContext sparkContext = sparkSession.sparkContext();
        JavaSparkContext javaSparkContext = new JavaSparkContext(sparkContext);

        sparkSession.close();
    }

}
